<?
// ABILITIES-CONDITIONS CHECK
if ($atacante->getValue('str') == 0) $atacante->getConditionStates()->adiciona('helpless');
if ($atacante->getValue('dex') == 0) $atacante->getConditionStates()->adiciona('paralyzed');
if ($atacante->getValue('con') == 0) $atacante->getConditionStates()->adiciona('dead');
if ($atacante->getValue('int') == 0 ||
	$atacante->getValue('wis') == 0 ||
	$atacante->getValue('car') == 0) $atacante->getConditionStates()->adiciona('unconscious');

if ($defensor->getValue('hp') == 0) $defensor->getConditionStates()->adiciona('disabled');
if ($defensor->getValue('hp') < 0) $defensor->getConditionStates()->adiciona('dying');
if ($defensor->getValue('hp') < -10) $defensor->getConditionStates()->adiciona('dead');
if ($defensor->getValue('nonLethalDamage') == $defensor->getValue('hp'))
	$defensor->getConditionStates()->adiciona('staggered');
if ($defensor->getValue('nonLethalDamage') > $defensor->getValue('hp'))
	$defensor->getConditionStates()->adiciona('unconscious');

// ATTACKER CONDITIONS
if ($atacante->getConditionStates()->existe('dazzled')) {
	$melee_attack_mod -= 1; $ranged_attack_mod -= 1;
}
if ($atacante->getConditionStates()->existe('entangled')) {
	$melee_attack_mod -= 2; $ranged_attack_mod -= 2;
}
if ($atacante->getConditionStates()->existe('flanking')) {
	$melee_attack_mod += 2; $ranged_attack_allowed = false;
}
if ($atacante->getConditionStates()->existe('invisible')) {
	$melee_attack_mod += 2; $ranged_attack_mod += 2;
}
if ($atacante->getConditionStates()->existe('prone')) {
	$melee_attack_mod -= 4; $ranged_attack_allowed = false;
}
if ($atacante->getConditionStates()->existe('shaken') || $atacante->getConditionStates()->existe('frightened') ) {
	$melee_attack_mod -= 2; $ranged_attack_mod -= 2;
}

// DEFENDER CONDITIONS
if ($defensor->getConditionStates()->existe('blinded')) {
	$armor_on_melee_mod -= 2; $armor_on_ranged_mod -= 2; $def_dex_mod > 0 ?  $def_dex_mod = 0 : true;
}
if ($defensor->getConditionStates()->existe('cowering')) {
	$armor_on_melee_mod -= 2; $armor_on_ranged_mod -= 2; $def_dex_mod > 0 ?  $def_dex_mod = 0 : true;
}
if ($defensor->getConditionStates()->existe('entangled')) {
	$armor_on_melee_mod += 0; $armor_on_ranged_mod += 0; $def_dex_mod -= 4;
}
if ($defensor->getConditionStates()->existe('flat-footed')) {
	$armor_on_melee_mod += 0; $armor_on_ranged_mod += 0; $def_dex_mod > 0 ?  $def_dex_mod = 0 : true;
}
if ($defensor->getConditionStates()->existe('grappling')) {
	$armor_on_melee_mod += 0; $armor_on_ranged_mod += 0; $def_dex_mod > 0 ?  $def_dex_mod = 0 : true;
}
if ($defensor->getConditionStates()->existe('helpless') || $defensor->getConditionStates()->existe('pinned')) {
	$melee_attack_mod += 4; $ranged_attack_mod += 0; $rogue_sneak_attack = true; $attack_autocritical = true;
}
if ($defensor->getConditionStates()->existe('kneeling') || $defensor->getConditionStates()->existe('sitting')) {
	$melee_attack_mod -= 2; $ranged_attack_mod += 2;
}
if ($defensor->getConditionStates()->existe('prone')) {
	$melee_attack_mod -= 4; $ranged_attack_mod += 4;
}
if ($defensor->getConditionStates()->existe('stunned')) {
	$armor_on_melee_mod -= 2; $armor_on_ranged_mod -= 2; $def_dex_mod > 0 ?  $def_dex_mod = 0 : true;
}
?>